<%-- 
    Document   : stockdb
    Created on : Jan 14, 2013, 8:21:16 PM
    Author     : Bittuji
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="db.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
        
        String product_id = request.getParameter("ptid");
        String product_name = request.getParameter("ptname");
        String product_cat = request.getParameter("ptcat");
        int quantity = Integer.parseInt(request.getParameter("qty"));
        float sprice = Float.parseFloat(request.getParameter("price"));
        float amount = Float.parseFloat(request.getParameter("amt"));
        
        String sql = "INSERT INTO `stock`(`product_id`, `product_name`, `product_cat`, `quantity`, `sell_price`, `amount`) VALUES (?,?,?,?,?,?) ";
        PreparedStatement pstmt = con.prepareStatement(sql);
        
        pstmt.setString(1, product_id);
        pstmt.setString(2, product_name);
        pstmt.setString(3, product_cat);
        pstmt.setInt(4, quantity);
        pstmt.setFloat(5, sprice);
        pstmt.setFloat(6, amount);
        
        int result = pstmt.executeUpdate();
        
        if(result==1)
            System.out.println("data inserted");
        
       
        %>
    </body>
</html>
